package cn.piggy.mail.controller;

import cn.piggy.mail.component.MailExecutor;
import cn.piggy.mail.model.query.DateQuery;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.mail.MessagingException;
import java.io.IOException;
import java.text.ParseException;

@Controller
public class MaiController {

    @Resource
    private MailExecutor mailExecutor;


    @ResponseBody
    @RequestMapping("/backup")
    public String test01() throws MessagingException, ParseException, IOException, IllegalAccessException {
        DateQuery dateQuery = new DateQuery();
        dateQuery.setStartTime("2024-01-03");
        dateQuery.setEndTime("2024-03-20");
        long l1 = System.currentTimeMillis();
        mailExecutor.handleMail(dateQuery);
        long l2 = System.currentTimeMillis();
        System.out.println("use time --> "+(l2-l1));
        return "test01";
    }
}
